import request from '@/utils/request_zc'

export function getBomList ({ keyword, page, limit }) {
  return request({
    url: '/mes/bom/list',
    method: 'get',
    params: {
      keyword,
      page,
      limit
    }
  })
}

export function getBomDetail ({ id }) {
  return request({
    url: `/mes/bom/detail/${id}`,
    method: 'get'
  })
}

export function editBom ({
  description,
  detailList,
  id,
  name,
  productModelId
}) {
  return request({
    url: '/mes/bom/edit',
    method: 'post',
    data: {
      description,
      detailList,
      id,
      name,
      productModelId
    }
  })
}

export function addBom (data) {
  return request({
    url: '/mes/bom/add',
    method: 'post',
    data
  })
}

export function delBom ({ ids }) {
  return request({
    url: '/mes/bom/del',
    method: 'post',
    data: {
      ids
    }
  })
}

export function getMaterialCategoryList () {
  return request({
    url: '/wms/material/category/list',
    method: 'get'
  })
}

export function getMaterialList ({
  page,
  limit,
  code,
  name,
  model,
  specication,
  unit,
  price,
  pid,
  type,
}) {
  return request({
    url: '/wms/material/list',
    method: 'get',
    params: {
      code,
      name,
      model,
      specication,
      unit,
      price,
      pid,
      type,
      page,
      limit
    }
  })
}

export function delMaterial (data) {
  return request({
    url: '/wms/material/del',
    method: 'post',
    data
  })
}

export function addMaterial ({
  category,
  code,
  name,
  model,
  specification,
  unit,
  price,
  type,
  remark
}) {
  return request({
    url: '/wms/material/add',
    method: 'post',
    data: {
      category,
      code,
      name,
      model,
      specification,
      unit,
      price,
      type,
      remark
    }
  })
}

export function editMaterial ({
  id,
  category,
  code,
  name,
  model,
  specification,
  unit,
  price,
  type,
  remark
}) {
  return request({
    url: '/wms/material/edit',
    method: 'post',
    data: {
      id,
      category,
      code,
      name,
      model,
      specification,
      unit,
      price,
      type,
      remark
    }
  })
}
